import Router from 'koa-router';
import proxyService from '../../../common/proxyService';
import {
  getBargainList,
  getBargainUserList,
  getBargainInfo,
  getHelpBargainList,
  deleteBargain,
  saveBargain,
  updateBargainStatus,
  getBargainUserInfo,
  updateBargain,
  getMerchantIntroduction,
  queryCorpGoodsList,
  queryGoodsBaseGroupListInfo,
  getMouldInfo,
  getStoreBypage,
  getValueByKeyFormBargain,
  getOfficialAppAccountId,
  getBargainGoods,
  checkPayType,
  getOfficialCssCustomTemplate,
} from '../../../api';

const router = new Router();

//
router.get('/getBargainList', async ctx => {
  console.log(ctx.request.query);
  const response = await proxyService.postProxy(ctx, getBargainList);
  return (ctx.body = response);
});

//
router.get('/getBargainInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getBargainInfo);
  return (ctx.body = response);
});

//
router.get('/getHelpBargainList', async ctx => {
  const response = await proxyService.postProxy(ctx, getHelpBargainList);
  return (ctx.body = response);
});

router.get('/getBargainUserList', async ctx => {
  const response = await proxyService.postProxy(ctx, getBargainUserList);
  return (ctx.body = response);
});

//
router.post('/deleteBargain', async ctx => {
  const response = await proxyService.postProxy(ctx, deleteBargain);
  return (ctx.body = response);
});

//
router.post('/saveBargain', async ctx => {
  const response = await proxyService.postProxy(ctx, saveBargain);
  return (ctx.body = response);
});

router.post('/updateBargain', async ctx => {
  const response = await proxyService.postProxy(ctx, updateBargain);
  return (ctx.body = response);
});

//
router.post('/updateBargainStatus', async ctx => {
  const response = await proxyService.postProxy(ctx, updateBargainStatus);
  return (ctx.body = response);
});

router.get('/getBargainUserInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getBargainUserInfo);
  return (ctx.body = response);
});

// 获取商家介绍信息
router.get('/getMerchantIntroduction', async ctx => {
  const response = await proxyService.postProxy(ctx, getMerchantIntroduction);
  return (ctx.body = response);
});

// 获取商品
router.get('/queryCorpGoodsList', async ctx => {
  const response = await proxyService.postProxy(ctx, queryCorpGoodsList);
  return (ctx.body = response);
});
router.get('/queryGoodsBaseGroupListInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, queryGoodsBaseGroupListInfo);
  return (ctx.body = response);
});

// 获取模板列表
router.get('/getMouldInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getMouldInfo);
  return (ctx.body = response);
});

// 门店
router.get('/getStoreBypage', async ctx => {
  const response = await proxyService.postProxy(ctx, getStoreBypage);
  return (ctx.body = response);
});

// 获取模板详情
router.get('/getValueByKeyFormBargain', async ctx => {
  const response = await proxyService.postProxy(ctx, getValueByKeyFormBargain);
  return (ctx.body = response);
});
// getOfficialAppAccountId
router.get('/getOfficialAppAccountId', async ctx => {
  const response = await proxyService.postProxy(ctx, getOfficialAppAccountId);
  return (ctx.body = response);
});

router.get('/getBargainGoods', async ctx => {
  const response = await proxyService.postProxy(ctx, getBargainGoods);
  return (ctx.body = response);
});

router.get('/checkPayType', async ctx => {
  const response = await proxyService.postProxy(ctx, checkPayType);
  return (ctx.body = response);
});
router.get('/getOfficialCssCustomTemplate', async ctx => {
  const response = await proxyService.postProxy(ctx, getOfficialCssCustomTemplate);
  return (ctx.body = response);
});

export default router;
